import http from '../utils/request';

interface RealName {
	certBackUrl ?: string;
	certFrontUrl ?: string;
	certId : string;
	certName : string;
}

interface Pages {
	tyjPageNum : number;
	tyjPageSize : number;
}

interface UserGoodsOrderData extends Pages {
	tabType : '0' | '1' | '3'
}

interface LoginBody {
	"appCommonLogReq" ?: {
		"mobile" : string
		"password" : string
	},
	"appWxLoginReq" ?: {
		"wxCode" : string
	},
	"cmsLoginReq" ?: {
		"mobile" : string,
		"password" : string,
		"vcode" : string
	},
	// "loginType" : 0 | 1 | 2 | 3,
	"miniLoginReq" ?: {
		"code" : string,
		"encryptedData" : string,
		"iv" : string,
		"recommenderInvitation" ?: string
		userHeadUrl ?: string,
		nickName ?: string,

	}
}
interface AddUserCard {
	"alipayPaymentAccount" ?: string,
	"bankName" ?: string,
	"bankcardNum" ?: string,
	"cardType" : "10001001" | '10001002' | '10001003' | '10001004',
	"phone" : string,
	"userCardId" ?: string
}

// 参数接口
interface GetStoreManagementOrderReportParams {
	businessType ?: string;
	endTime ?: string;
	startTime ?: string;
}


// 实名认证信息添加
export function addUserAuth(params : RealName) : Promise<any> {
	return http('/api/auth/user/auth/addUserAuth', params, 'POST')
}

// 获取个人信息
export function getUserInfo() : Promise<any> {
	return http('/api/user/getUserVo')
}
// 实名认证信息---查询
export function getSelfAuth() : Promise<any> {
	return http('/api/auth/user/auth/getSelfAuth')
}

// 修改个人信息
export function editUserInfo(params : { nickName ?: string, userHeadUrl ?: string }) : Promise<any> {
	return http('/api/auth/user/editUserInfo', params, 'POST')
}

// 登录
export function loginIn(params : LoginBody) : Promise<any> {
	return http('/api/login/loginIn', params, 'POST')
}
// 注册
export function register(params : RegisterParams) : Promise<RegisterRes> {
	return http('/api/unAuth/user/register', params, 'POST') as any
}

// 我的收益---福利明细
export function getApiAccountWelfareList(params : Pages) : Promise<any> {
	return http('/api/auth/user/account/freeze/getApiAccountWelfareList', params, 'POST')
}

// 我的收益---提现明细
export function getApiAccountCashList(params : Pages) : Promise<any> {
	return http('/api/auth/user/cash/getApiAccountCashList', params, 'POST')
}
// 我的收益---提现详情
export function getApiCashDetail(params : { orderId : string }) : Promise<any> {
	return http('/api/auth/user/cash/getApiCashDetail', params,)
}
// 提现
export function addCashOrder(params : { amount : number, userCardId : string }) : Promise<any> {
	return http('/api/auth/user/cash/addCashOrder', params, 'POST')
}
// 获取提现信息列表
export function getApiUserCardList() : Promise<any> {
	return http('/api/auth/user/card/getApiUserCardList')
}
// 获取提现账户详情
export function getUserCardDetail(params : { userCardId : string }) : Promise<any> {
	return http('/api/auth/user/card/getUserCardDetail', params)
}
// 获取提现账户详情新接口
export function getUserCardDetailNew() : Promise<any> {
	return http('/api/user/card/getUserCardDetailNew')
}
// 修改提现方式
export function modifyUserCard(params : AddUserCard) : Promise<any> {
	return http('/api/auth/user/card/modifyUserCard', params, 'POST')
}

// 添加提现方式
export function addUserCard(params : AddUserCard) : Promise<any> {
	return http('/api/auth/user/card/addUserCard', params, 'POST')
}
// 删除提现方式
export function deleteBankCard(params : { userCardId : string }) : Promise<any> {
	return http('/api/auth/user/card/delete', params, 'DELETE')
}


// 我的收益---优惠明细
export function getApiAccountDiscountList(params : Pages) : Promise<any> {
	return http('/api/auth/user/account/change/getApiAccountDiscountList', params, 'POST')
}
// 我的收益---头部信息
export function getAccountBrokerageAmount() : Promise<any> {
	return http('/api/auth/user/account/getAccountBrokerageAmount')
}
// 获取邀请好友-个人推荐页面信息
export function getInvitationInfo() : Promise<any> {
	return http('/api/auth/user/getInvitationInfo')
}
// 通过手机号查询用户信息
export function getUserByMobile(params : { mobile : string }) : Promise<GetUserByMobileRes> {
	return http('/api/auth/user/getUserByMobile', params)
}

// 确认注销
export function checkLogOutSmsCode(code : string) : Promise<DefaultRes> {
	return http('/api/auth/user/userInfo/checkLogOutSmsCode', code, 'POST') as any
}
// 用户账户注销申请提交
export function submitLogout(params : { mobile : string, smsCode : number | string }) : Promise<DefaultRes> {
	return http('/api/auth/user/userInfo/submitLogout', params, 'POST') as any
}
// 优惠金转赠
export function createTransferOrder(params : { giveAccountAmount : number, mobile : string }) : Promise<DefaultRes> {
	return http('/api/auth/user/transfer/createTransferOrder', params, 'POST') as any
}
// 获取支付code
export function getOpenIdByCode(params : { code : string }) : Promise<DefaultRes> {
	return http('/api/unAuth/login/getOpenIdByCode', params) as any
}
// 经营报表-订单统计
export function getStoreManagementOrderReport(params : GetStoreManagementOrderReportParams) : Promise<GetStoreManagementOrderReportRes> {
	return http('/api/auth/mer/store/getStoreManagementOrderReport', params, 'POST') as any
}
// 营报表-员工统计
export function getStoreManagementStaffReport(params : GetStoreManagementOrderReportParams) : Promise<GetStoreManagementOrderReportRes> {
	return http('/api/auth/mer/store/getStoreManagementStaffReport', params, 'POST') as any
}

// 提交加盟申请
export function joinApplySubmit(params : SubmitParams) : Promise<DefaultRes> {
	return http('/api/auth/joinApply/submit', params, 'POST') as any
}

// 查询核销员详情
interface GetMerClerkRes {
	code : number;
	data : {
		clerkName : string;
		commissionAuth : number;
		customerAuth : number;
		endMarketRate : number;
		entryStatus : string;
		goodsAuth : number;
		id : string;
		merId : string;
		mobile : string;
		orderAuth : number;
		serviceAuth : number;
		startMarketRate : number;
		status : string;
		storeId : string;
		userId : string;
		workOrderAuth : number;
		storeRate : number;
	};
	msg : string;
}
export function getclerkDetail(params : { mobile ?: string, userId ?: string }) : Promise<GetMerClerkRes> {
	return http('/api/auth/mer/clerk/detail', params) as any
}